import React,{Component,View,StyleSheet,Navigator,Text,BackAndroid} from 'react-native';
//组件
import BwMain from './bwmain'
import BwSet from './bwset'
import MainScreenWithDraw from './mainScreenWithDraw'
import LoginScreen from '../components/loginScreen/login'

var _navigator;
BackAndroid.addEventListener('hardwareBackPress', function() {
  if (_navigator && _navigator.getCurrentRoutes().length > 1) {
    _navigator.pop();
    return true;
  }
  return false;
});

export default class mainScreen extends Component {
  static propTypes = {
    name: React.PropTypes.string,
  };

  constructor(props) {
    super(props);
  }


  //路由映射
  RouteMapper=(route, navigator, onComponentRef)=>{
    _navigator=navigator;
    //登录页面
    if(route.name=="login"){
      return(
        <LoginScreen navigator={navigator}></LoginScreen>
      )
    }
    //主页面
    if (route.name==='mainScreen') {
      return(
        <MainScreenWithDraw navigator={navigator}></MainScreenWithDraw>
      )
    };
    //单击每一个bwlist的时候跳转
    if (route.name==='bwList') {
      return(
        <BwMain navigator={navigator} >
        </BwMain>
      )
    };
    //查看bw的配置参数
    if (route.name==='bwSet') {
      return(
        <BwSet navigator={navigator}></BwSet>
      )
    };
  };
  render() {
    return (
      <Navigator
        style={{flex:1}}
        initialRoute={{name: 'login'}}
        configureScene={() => Navigator.SceneConfigs.FadeAndroid}//转场动画
        renderScene={this.RouteMapper}
      />
    );
  }
}

const styles = StyleSheet.create({

});